<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="<%=path %>/static/css/css.css?1" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/jquery-ui/jquery-ui.min.css" />
<script type="text/javascript" src="<%=path %>/static/js/json2.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/static/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=path %>/static/layer/layer.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/gridview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/formview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/tool.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/validate.js"></script>
<script type="text/javascript" src="<%=path %>/wechat/js/copy/ZeroClipboard.js"></script>
<SCRIPT type="text/javascript">
    <!--
	var gridSetting = {
			id:'QhNoviceTaskGrid',
			po:"QhNoviceTask",
			title:'新手任务列表',
			height:'auto',
			service:"uiServices!listSimple",
			tbId:"TaskTb",
			pageInfo: {
				records: 12,//auto表示根据容器高度自动判断
				orderby : "sort"
			},
			oper:{
                isDisplay:true,
            	operName:"",
            	url:"",
            	cssClass:"Operation",
            	width:120
            },
			fields:[
			   {	name:'id',
					hide:true
			   },{
                    name: 'sort',
                    descs:"排序",
                    align:'center',
                    thstyle:"width:60px"
               }
			   ,{
                   name: 'type',
                   descs:"类别",
                   thstyle:"width:80px"
               },
               {
                   name: 'name',
                   descs:"标题",
                   thstyle:"width:120px"
               },
               {
                   name: 'cnt',
                   descs:"数量",
                   thstyle:"width:80px",
                   align:'right'
               },
               {
				   name: 'sigleCashMoney',
				   descs:"单价",
				   thstyle:"width:80px",
				   align:'right'
			   },{
                   name: 'cashMoney',
                   descs:"总额",
                   align:'right',
                   thstyle:"width:80px"
               }
               ,{
                   name: 'effectTime',
                   descs:"有效时间",
                   align:'center',
                   thstyle:"width:130px",
                   type:'datetime'
               }
               ,{
                   name: 'state',
                   descs:"状态",
                   type:'state',
                   staval:{'99':'未审核','1':'已审核','-1':'已终止'},
                   thstyle:"width:60px",
               }
			]
		};
	var grid,form0;
    $(document).ready(function(){
    	grid = new GridView("list",gridSetting,"list");
		grid.init();
		var data = [];
		grid.load({data:data});

		ajustHeight();

		$("#addBtn").click(function(){
		   location.href="/qh/public/common/r2.htmls?page=task/novice_task_edit";
		});

		$("#delBtn").click(function(){
		   grid.deletes("deleteMappedRoleNavis",function(ret){
              if(ret==-1){
                 layer.msg("删除失败，请重试！");
              }else{
                 layer.msg("删除" + ret.recordNum + "条记录！",function(ret){
                    grid.reload();
                 });
              }
           });
		});

    });

    //-->
</SCRIPT>
</head>

<body>
<ul class=tab_nav>
  <li>
    <a class="current" href="javascript:void(0)">新手任务</a>
  </li>
</ul>
<div class="contrainer">
<div class="rcon2" >
<table class="search_tb">
   <tr>
      <td>
         <select name="type" style="width:100px;display:none">
            <option value="">类型</option>
            <option value="新手任务">新手任务</option>
            <option value="普通任务">普通任务</option>
         </select>
      </td>
      <td>
         <select name="state" style="width:80px;">
            <option value="">状态</option>
            <option value="99">未审核</option>
            <option value="1">已审核</option>
            <option value="-1">已终止</option>
         </select>
      </td>
      <td><input type="text" name="title" placeholder="任务标题" /></td>
      <td><input type="text" name="adver" placeholder="广告主" /></td>
      <td>
         <div style="float:left">
            <input type="text" onclick="WdatePicker()" name="effectTime" placeholder="开始时间" />-<input type="text" onclick="WdatePicker()" name="effectTime" placeholder="结束时间" />
         </div>
         <input type="button" class="searchbtn" value="" id="queryBtn">
      </td>
      <td>
         <input type="button" class="btnblue" value="新增" id="addBtn" >
         <input type="button" class="btnblue" value="删除" id="delBtn"" >
      </td>
   </tr>
</table>
</div>
<div id="formview" class="rbox1"></div>
<div id="list" class="rbox2"></div>
</div>
<script type="text/javascript" src="<%=path %>/static/js/underscore.js"></script>
<script type='text/javascript' src='<%=path %>/static/My97DatePicker/WdatePicker.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/interface/BaseDwr.js'></script>
<script>
    $("#queryBtn").click(function(){
       var Title = $(".search_tb").find(":input[name=title]").val();
       var adver = $(".search_tb").find(":input[name=adver]").val();
       var effectTime1 = $(".search_tb").find(":input[name=effectTime]:eq(0)").val();
       var effectTime2 = $(".search_tb").find(":input[name=effectTime]:eq(1)").val();
       var state = $(".search_tb").find(":input[name=state]").val();
       var type = $(".search_tb").find("select[name=type]").val();
       var data = [];
       if(Title!==""){
          data.push({r:"like",name:'title',value:"%"+Title+"%"});
       }
       if(adver!==""){
          data.push({r:"like",name:'adver',value:"%"+adver+"%"});
       }
       if(effectTime1!==""){
          data.push({r:">=",name:'effectTime',value:effectTime1});
       }
       if(effectTime2!==""){
          data.push({r:"<=",name:'effectTime',value:effectTime2});
       }
       if(state!==""){
          data.push({r:"=",name:'state',value:state});
       }
       if(type!==""){
          data.push({r:"=",name:'type',value:type});
       }

       grid.load({data:data});
       ajustHeight();
    });
    function afterLoad_TaskTb(){
       $(".rcon2 .mtable tbody tr").each(function(){
          var id=$(this).attr("recordid");
          var html="<a href=<%=path %>/public/common/r2.htmls?page=task/novice_task_edit&id="+id+" >编辑</a>";
          var state=$(this).find("td[name=state]").attr("staval");
          if(state!=-1&&state!=99){
             html+="<a href=javascript:end("+id+",-1) style='margin-left:6px;' >终止</a>";
          }
          if(state==99){
             html+="<a href=javascript:end("+id+",1) style='margin-left:6px;' >审核</a>";
          }

          $(this).find(".Operation").html(html);
       });
    }
    function end(id,state){
       $.getJSON(g_path+"/public/common/noviceTaskStateEdit.htmls",{id:id,state:state},function(data){
          layer.alert("操作成功！");
          grid.reload();
       });
    }
</script>
</body>
</html>